<?php
/* @var $this PegawaiController */
/* @var $model Pegawai */
/* @var $form CActiveForm */
?>
<?php $this->beginWidget('ext.widgets.XPanel', array('title' => 'Pegawais', 'width' => 900,'height' => 500)); 
?>
<div class="form">

<?php $form=$this->beginWidget('ext.CAxActiveForm', array(
	'id'=>'pegawai-form',
        'enableAjaxValidation'=>true,
        'enableClientValidation'=>true,
        'clientOptions'=>array(
                'validateOnSubmit'=>true,
        ),
        'htmlOptions'=>array(
                    'onsubmit'=>"console.log(value);return false;",/* Disable normal form submit */
                    'onkeypress'=>" if(event.keyCode == 13){ send(); } " /* Do ajax call when user presses enter key */
                    )

)); 
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>
    <table class="ma-table">
        <tbody>
	<tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'nama'); ?>
</td>
		<td><?php echo CHtml::activeTextField($model,'nama'); ?>
</td>
		<td><?php echo $form->error($model,'nama'); ?>
</td>
	</tr>

	<tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'nip'); ?>
</td>
		<td><?php echo CHtml::activeTextField($model,'nip'); ?>
</td>
		<td><?php echo $form->error($model,'nip'); ?>
</td>
	</tr>

	<tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'alamat'); ?>
</td>
		<td><?php echo CHtml::activeTextField($model,'alamat'); ?>
</td>
		<td><?php echo $form->error($model,'alamat'); ?>
</td>
	</tr>

	<tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'no_telp'); ?>
</td>
		<td><?php echo CHtml::activeTextField($model,'no_telp'); ?>
</td>
		<td><?php echo $form->error($model,'no_telp'); ?>
</td>
	</tr>
        <tr>
		<td class="labelfield" style="width:200px">
                    <?php echo $form->labelEx($model,'password'); ?>
                </td>
		<td>
                    <?php echo CHtml::activeTextField($model,'password'); ?>
                </td>
		<td>
                    <?php echo $form->error($model,'password'); ?>
                </td>
	</tr>
        <tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'Struktur Organisasi'); ?>
                </td>
                <td><?php 
                
                    echo CHtml::dropDownList('id_struktur_organisasi', 
                            '', 
                            StrukturOrganisasi::model()->reformatList(),
                            array(
                                'ajax' => array(
                                    'type'=>'POST', //request type
                                    'url'=> Yii::app()->createUrl('/Jabatan/getList'),
                                    'update'=>'#Pegawai_id_jabatan', //selector to update
                                ), 
                                'empty'=>'Pilih Organisasi',
                                'options'=>array(
                                        (!isset($jabatan->id_struktur_organisasi))? "" : $jabatan->id_struktur_organisasi => array('selected'=>TRUE)
                                    )
                            )
                        );
                    ?></td>
                <td></td>
	</tr>
        
	<tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'jabatan'); ?>
                </td>
                <td><?php
                    if(!empty($jabatanList))
                        echo CHtml::activeDropDownList($model,'id_jabatan', CHtml::listData($jabatanList, 'id_jabatan', 'nama'));
                    else
                        echo CHtml::dropDownList('Pegawai[id_jabatan]','', array());;
                    ?>
                </td>
                        <td><?php echo $form->error($model,'id_jabatan'); ?>
                </td>
	</tr>
        
        <tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'id_group'); ?>
                </td>
                <td><?php 
                
                    echo CHtml::dropDownList('Pegawai[id_group]', 
                            '', 
                            CHtml::listData(
                                    Group::model()->findAll(), 'id_group', 'nama'
                                    ),
                            array(
                                'empty'=>'Pilih Grup',
                            )
                        );
                    ?></td>
                <td></td>
	</tr>
        

	<tr>
		<td></td>
                <td><?php echo CHtml::submitButton('Save', array('class'=>'ax-btn')); ?>
</td>
                <td></td>
	</tr>
        </tbody>
    </table>
<?php $this->endWidget(); ?>

</div><!-- form -->
<?php $this->endWidget(); ?>